<table class="table table-hover no-margins">
    <thead>
    <tr>
        <th>序号</th>
        <th>任务名称</th>
        <th>任务类型</th>
        <th>时间</th>
        <th>任务状态</th>
        <th>发送成功</th>
        <th>未发送</th>
        <th>发送失败</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>

        <tr ng-repeat="item in vm.smsList">
            <td>{{item.index + 1}}</td>
            <td>{{item.name}}</td>
            <td>{{item.type == 'score' ? '成绩短信' : item.type == 'register' ? '报名短信' : item.type == 'cancelreg' ? '取消报名短信' : item.type == 'claimpack' ? '领取赛包短信' : '群发任务'}}</td>
            <td>{{item.trigger_time}}</td>
            <!-- 发送状态 -->
            <td>{{item.status == 'halt' ? '已取消' : (item.status == 'done' ? '已完成' : item.real_status)}}</td>
            <td>{{item.send_success}}</td>
            <td>{{item.send_pending}}</td>
            <td>{{item.send_fail}}</td>
            <td>
                <button ng-show="item.status != 'done' && item.status != 'halt'" type="button" class="btn btn-sm btn-default" ng-click="vm.cancelDialog(item.id)">取消</button>
                <button ng-show="item.status != 'done' && item.status != 'halt'" type="button" class="btn btn-sm btn-primary" ng-click="vm.edit(item.id)">编辑</button>
            </td>
        </tr>
       
        <tr>
            <td>
                <button type="button" class="btn btn-sm btn-primary" ng-click="vm.edit()">新增</button>
            </td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
    </tbody>
</table>                    



<form class="form-horizontal margin-top-20" name="serviceForm" ng-submit="vm.submitForm(serviceForm.$valid)" ng-show="vm.formshow" novalidate>
    <div class="form-group">
        <label class="col-lg-3 control-label">任务类型 <b class="text-danger">*</b></label>
        <div class="col-lg-6">
            <label class="radio">
                <input icheck type="radio" name="type" value="register" ng-model="vm.service.type" ng-disabled='vm.smsRegisterFlag' ng-change="vm.selectSmsTypeRegister()"> 报名短信（自动发送） </input><span ng-show="vm.smsRegisterFlag" class="text-danger"> 报名短信已存在，不能重复提交</span>
            </label>
            <label class="radio">
                <input icheck type="radio" name="type" value="cancelreg" ng-model="vm.service.type" ng-disabled='vm.smsCancelRegFlag' ng-change="vm.selectSmsTypeRegister()"> 取消报名短信（自动发送） </input><span ng-show="vm.smsCancelRegFlag" class="text-danger"> 取消报名短信已存在，不能重复提交</span>
            </label>
            <label class="radio">
                <input icheck type="radio" name="type" value="claimpack" ng-model="vm.service.type" ng-disabled='vm.smsClaimPackFlag' ng-change="vm.selectSmsTypeRegister()"> 领取赛包短信（自动发送） </input><span ng-show="vm.smsClaimPackFlag" class="text-danger"> 领取赛包已存在，不能重复提交</span>
            </label>
            <label class="radio">
                <input icheck type="radio" name="type" value="score" ng-model="vm.service.type" ng-disabled='vm.smsScoreFlag' ng-change="vm.selectSmsTypeScore()"> 成绩短信（自动发送） </input><span ng-show="vm.smsScoreFlag" class="text-danger"> 成绩短信已存在，不能重复提交</span>
            </label>
            <label class="radio">
                <input icheck type="radio" name="type" value="now" ng-model="vm.service.type"> 立即发送
            </label>
            <label class="radio">
                <input icheck type="radio" name="type" value="plan" ng-model="vm.service.type"> 定时发送
                <!-- <input type="datetime-local" ng-model="vm.service.datetime"> -->

                <div ng-show="vm.service.type == 'plan'">
                    <div class="input-group date col-lg-6 margin-top-10">
                        <input name="startTime" type="text" size="10" class="form-control" ng-model="vm.service.date" data-date-format="yyyy-MM-dd" data-autoclose="1" placeholder="年-月-日" bs-datepicker>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                    <div class="input-group date col-lg-6 margin-top-10">
                        <input name="startTime" type="text" size="10" class="form-control" ng-model="vm.service.time" data-time-format="HH:mm:ss" data-autoclose="1" placeholder="时:分:秒" bs-timepicker required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>

            </label>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-3 control-label">任务名称 <b class="text-danger">*</b></label>
        <div class="col-lg-3">
            <input type="text" name="courseName" class="form-control" placeholder="请输入任务名称" ng-model="vm.service.name" required>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-3 control-label">科目</label>
        <div class="col-lg-3">
            <select class="form-control" ng-model="vm.service.course" ng-change="vm.changeSelect()" ng-disabled="vm.service.type == 'score' || vm.service.type == 'register' || vm.service.type == 'cancelreg' || vm.service.type == 'claimpack'">
                <option value="">全部</option>  
                <option ng-repeat="item in vm.courselist" value="{{item.course_id}}">{{item.course_name}}</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-3 control-label">组别</label>
        <div class="col-lg-3">
            <select name="group" class="form-control" ng-model="vm.service.group" ng-change="vm.changeSelect()" ng-disabled="vm.service.type == 'score' || vm.service.type == 'register' || vm.service.type == 'cancelreg' || vm.service.type == 'claimpack'">  
                <option value="">全部</option>
                <option ng-repeat="gulp in vm.gulpSelect" value="{{gulp.value}}" ng-disabled="gulp.disabled">{{gulp.title}}</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-3 control-label">性别</label>
        <div class="col-lg-3">
            <select class="form-control" ng-model="vm.service.sex" ng-change="vm.changeSelect()" ng-disabled="vm.service.type == 'score' || vm.service.type == 'register' || vm.service.type == 'cancelreg' || vm.service.type == 'claimpack'">
                <option value="">全部</option>
                <option value="male">男</option>
                <option value="female">女</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-3 control-label">选手状态</label>
        <div class="col-lg-3">
            <select class="form-control" ng-model="vm.service.state" ng-change="vm.changeSelect()" ng-disabled="vm.service.type == 'score' || vm.service.type == 'register' || vm.service.type == 'cancelreg' || vm.service.type == 'claimpack'">
                <option value="">全部</option>
                <option value="normal">正常</option>
                <option value="finished">完赛</option>
                <option value="dnf">DNF</option>
                <option value="dns">DNS</option>
            </select>
        </div>
    </div>
    <div class="form-group">
        <div class="col-lg-offset-3 col-lg-6">
            <p class="help-block text-danger">目标人数：{{vm.smsTargets}} 人</p>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-3 control-label">短信服务</label>
        <div class="col-lg-6">
            <div class="row">
                <div class="col-lg-6 margin-bottom-20">
                    <textarea id="textarea" class="form-control" placeholder="输入你想发送的短信内容" rows="6" ng-model="vm.service.textarea" textarea-title=""></textarea>
                </div>
                <div class="col-lg-6 margin-bottom-20">
                    <ul class="label-list">
                        <li>
                            <button type="button" class="btn btn-xs btn-info" ng-click="vm.addText('{runner_name}')">
                                <i class="fa fa-plus"></i>
                                姓名
                            </button>
                        </li>
                        <li>
                            <button type="button" class="btn btn-xs btn-info" ng-click="vm.addText('{runner_gender}')">
                                <i class="fa fa-plus"></i>
                                性别
                            </button>
                        </li>
                        <li>
                            <button type="button" class="btn btn-xs btn-info" ng-click="vm.addText('{race_name}')">
                                <i class="fa fa-plus"></i>
                                比赛全名
                            </button>
                        </li>
                        <li>
                            <button type="button" class="btn btn-xs btn-info" ng-click="vm.addText('{course_name}')">
                                <i class="fa fa-plus"></i>
                                科目名称
                            </button>
                        </li>
                        <li>
                            <button type="button" class="btn btn-xs btn-info" ng-click="vm.addText('{runner_bib}')">
                                <i class="fa fa-plus"></i>
                                参赛号
                            </button>
                        </li>
                        <li>
                            <button type="button" class="btn btn-xs btn-info" ng-click="vm.addText('{gun_time}')">
                                <i class="fa fa-plus"></i>
                                枪声成绩
                            </button>
                        </li>
                        <li>
                            <button type="button" class="btn btn-xs btn-info" ng-click="vm.addText('{net_time}')">
                                <i class="fa fa-plus"></i>
                                净成绩
                            </button>
                        </li>
                        <li>
                            <button type="button" class="btn btn-xs btn-info" ng-click="vm.addText('{chip_no}')">
                                <i class="fa fa-plus"></i>
                                芯片号
                            </button>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-3 control-label">短信预览</label>
        <div class="col-lg-3">
            <textarea class="form-control" rows="6" ng-model="vm.service.previewText" disabled></textarea>
            <div class="count-txt">已输入<strong class="current-length">{{vm.service.previewText?vm.service.previewText.length:0}}</strong>字，计<strong class="current-length">{{vm.textLength}}</strong>条短信</div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg-3 control-label">测试发送</label>
        <div class="col-lg-6">
            <div class="row">
                <div class="col-lg-6 margin-bottom-20">
                    <input type="text" name="phone" class="form-control" placeholder="请输入手机号码" ng-model="vm.service.phone">
                </div>
                <div class="col-lg-6 margin-bottom-20">
                    <button type="button" class="btn btn-sm btn-primary loading-text" ng-class="{active: !loadingText}" ng-click="vm.sendMsg(vm.service.phone)" loading-text="80" ng-disabled="!vm.service.phone || !loadingText">立即发送测试短信</button>
                </div>
            </div>
        </div>
    </div>
    <div class="form-group">
        <div class="col-lg-offset-3 col-lg-6">
            <button type="button" class="btn btn-sm btn-default" ng-click="vm.cancelform()">取消</button>
            <button type="submit" class="btn btn-sm btn-primary">{{ vm.service.type == 'now' ? '立即发送' : '保存' }}</button>
        </div>
    </div>
</form>